#ifndef DEFINE_H
#define DEFINE_H

#include <QString>
#include <QList>
#include <QMap>


#define YEAR_START                      "-01-01 00:00:00"
#define YEAR_END                        "-12-31 23:59:59"
#define MONTH_START                     "-01 00:00:00"
#define MONTH_END                       "-%1 23:59:59"




#define SELECT_LOGIN_INFO              "select *  from cmf_user"

#define SELECT_CUSTOMER_DATA           "select dept_id,dept_parent_id,dept_name ,dept_order_id from cmf_dept"

#define SELECT_USERS_BY_DEPTID         "select * from cmf_user where dept_id = %1"

#define SELECT_USERS_BY_DEPTIDALL      "select * from cmf_user "

#define SELECT_CUSTOMER_DATA_LIMIT     "select * from customer_data limit %1"

#define SELECT_USERNAME                "select user_nickname from cmf_user"

#define DEFAULT_SQL_1                   "select cmf_dept.dept_name, cmf_user.user_nickname ,cmf_orders.* from cmf_orders \
                                        inner join cmf_user on cmf_user.id=cmf_orders.order_employees \
                                        inner join cmf_dept on cmf_dept.dept_id=cmf_user.dept_id"

#define DEFAULT_SQL                    "select cmf_user.user_nickname ,cmf_orders.* from cmf_orders \
                                        inner join cmf_user on cmf_user.id=cmf_orders.order_employees "

#define DEFAULT_CUSTOMER_SQL           "select cmf_dept.dept_name ,cmf_orders.order_create_time ,cmf_user.user_nickname ,cmf_orders.order_phone \
                                        from cmf_orders \
                                        inner join cmf_user on cmf_user.id=cmf_orders.order_employees \
                                        inner join cmf_dept on cmf_dept.dept_id=cmf_user.dept_id"

#define GET_ORDERS_DATE                "select order_create_time from cmf_orders order by order_create_time"

#define GET_VIP_LEVEL                  "select level_name from cmf_level"



struct DeptNode {
    int deptid;
    int parentid;
    QString deptname;
    int deptorderid;
    DeptNode(){
        deptid = -1;
        parentid = -1;
        deptorderid = -1;
        deptname = "empty";
    }

};

typedef QMap<QString ,DeptNode> DeptIdForNode;

struct UserInfo{
    int     id          = -1;
    int     user_type   = 0;
    int     sex         = 0;
    QString birthday;
    QString last_login_time;
    QString score;
    QString coin;
    QString balance;
    QString create_time;
    QString user_status;
    QString user_login;
    QString user_pass;
    QString user_nickname;
    QString user_email;
    QString user_url;
    QString avatar;
    QString signature;
    QString last_login_ip;
    QString user_activation_key;
    QString mobile;
    QString more;
    int dept_id = 0;
    QString dept_path;
    QString user_job;
};

//==================================user===========================================
#define CMF_USER_ID                     0//"id"
#define CMF_USER_USER_TYYE              1//"user_type"             //用户类型;1:admin;2:会员
#define CMF_USER_SEX                    2//"sex"                   //性别;0:保密,1:男,2:女
#define CMF_USER_BIRTHDAY               3//"birthday"              //生日
#define CMF_USER_LAST_LOGIN_TIME        4//"last_login_time"       //最后登录时间
#define CMF_USER_SCORE                  5//"score"                 //用户积分
#define CMF_USER_COIN                   6//"coin"                  //金币
#define CMF_USER_BALANCE                7//"balance"               //余额
#define CMF_USER_CREATE_TIME            8//"create_time"           //注册时间
#define CMF_USER_USER_STATUS            9//"user_status"           //用户状态;0:禁用,1:正常,2:未验证
#define CMF_USER_USER_LOGIN             10//"user_login"            //用户名
#define CMF_USER_USER_PASS              11//"user_pass"             //登录密码;cmf_password加密
#define CMF_USER_USER_NICKNAME          12//"user_nickname"         //用户昵称
#define CMF_USER_USER_EMAIL             13//"user_email"            //用户登录邮箱
#define CMF_USER_USER_URL               14//"user_url"              //用户个人网址
#define CMF_USER_USER_JOB               15//"user_url"              //用户个人网址
#define CMF_USER_AVATAR                 16//"avatar"                //用户头像
#define CMF_USER_SIGNATURE              17//"signature"             //个性签名
#define CMF_USER_LAST_LOGIN_IP          18//"last_login_ip"         //最后登录ip
#define CMF_USER_USER_ACTIVATION_KEY    19//"user_activation_key"   //激活码
#define CMF_USER_MOBILE                 20//"mobile"                //中国手机不带国家代码，国际手机号格式为：国家代码-手机号
#define CMF_USER_MORE                   21//"more"                  //扩展属性
#define CMF_USER_DEPT_ID                22//"dept_id"               //部门名称
#define CMF_USER_DEPT_PATH              23//"dept_path"             //部门路径
//=================================================================================

//==================================dept===========================================
#define CMF_DEPT_ID                     "dept_id"
#define CMF_DEPT_PARENT_ID              "dept_parent_id"
#define CMF_DEPT_ORDER_ID               "dept_order_id"
#define CMF_DEPT_NAME                   "dept_name"
//=================================================================================

struct OrdersInfo{
    int     order_id        = -1;
    int     order_employees = -1;
    uint8_t status;
    QString create_time;
    QString update_time;
    QString delete_time;
    QString order_person_name;
    QString order_vip_level;
    QString order_phone;
    QString order_spend_habits;
    QString order_note;
    QString order_create_time;
    QString order_estate_time;
};

//==================================orders===========================================
#define CMF_ORDERS_ID                   0//"order_id"                  //
#define CMF_ORDERS_EMPLOYEES            1//"order_employees"           //创建者id
#define CMF_ORDERS_CREATE_TIME          2//"create_time"               //
#define CMF_ORDERS_UPDATE_TIME          3//"update_time"               //
#define CMF_ORDERS_DELETE_TIME          4//"delete_time"               //
#define CMF_ORDERS_PERSON_NAME          5//"order_person_name"         //客户称谓
#define CMF_ORDERS_VIP_LEVLE            6//"order_vip_level"           //会员登记
#define CMF_ORDERS_PHONE                7//"order_phone"               //电话号码
#define CMF_ORDERS_SPEND_HABITS         8//"order_spend_habits"        //消费倾向
#define CMF_ORDERS_NODE                 9//"order_note"                //特殊备注
#define CMF_ORDERS_ORDER_CREATE_TIME    10//"order_create_time"         //订台时间
#define CMF_ORDERS_ORDER_ESTATE_TIME    11//"order_estate_time"         //预计到场日期

//=================================================================================


#endif // DEFINE_H
